package com.feonix.support.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.feonix.common.BaseInfo;
import com.feonix.common.util.StringUtil;
import com.feonix.common.util.mvc.ControllerUtil;
import com.feonix.common.view.menu.Menu;
import com.feonix.common.view.menu.MenuItem;

@Controller
@RequestMapping(value = "manager/main")
public class MainFrameController {
	private static final String PAGE = "home/honey"; // 登录后第一个页面

	private static final String MENU = ""; // 登录后第一个下拉菜单

	@RequestMapping("index")
	public ModelAndView showMainPage() {
		ModelAndView modelAndView = new ModelAndView("support/mainframe");
		modelAndView.addObject("pageUrl", PAGE);
		modelAndView.addObject("menuUrl", MENU);

		Menu menu = Menu.getInstance();

		/* 欢迎页面 */
		menu.addMenuItem(MenuItem
				.getInstance("honey", null, "Honey", ControllerUtil.getAbsolutePath("/manager/main/home/honey"))
				.setChannel("honey").setAllowed(true, false).setPermission("honey", null));

		/* 开发指南 */
		menu.addMenuItem(MenuItem
				.getInstance("develop", null, "开发指南", ControllerUtil.getAbsolutePath("/manager/main/develop/menu/show"),
						ControllerUtil.getAbsolutePath(
								"/manager/main/develop/component/tree?treeNodeName=" + StringUtil.encoder("树形菜单")))
				.setChannel("develop").setAllowed(true, false));

		/* 系统管理菜单 */
		menu.addMenuItem(MenuItem.getInstance("sysManage", null, "系统管理").setChannel("sysManage").setSeparator(true)
				.setAllowed(true, true));

		menu.addMenuItem(MenuItem.getInstance("groupManage", "sysManage", "机构管理",
				ControllerUtil.getAbsolutePath("/manager/main/group/groupmenu_show"),
				ControllerUtil.getAbsolutePath("/manager/main/group/group_list")).setAllowed(true, true));

		menu.addMenuItem(MenuItem.getInstance("userManage", "sysManage", "用户管理",
				ControllerUtil.getAbsolutePath("/manager/main/user/usermenu_show"),
				ControllerUtil.getAbsolutePath("/manager/main/user/user_list")).setAllowed(true, true));

		menu.addMenuItem(MenuItem.getInstance("roleManage", "sysManage", "角色管理",
				ControllerUtil.getAbsolutePath("/manager/main/role/role_list")).setAllowed(true, false));
		
		menu.addMenuItem(MenuItem.getInstance("rightManage", "sysManage", "功能管理",
				ControllerUtil.getAbsolutePath("/manager/main/right/right_list")).setAllowed(true, false));
		
		menu.addMenuItem(MenuItem.getInstance("banManage", "sysManage", "封停管理",
				ControllerUtil.getAbsolutePath("/manager/main/banlist/ban_list")).setAllowed(true, false));

		menu.addMenuItem(MenuItem
				.getInstance("sysParamManage", "sysManage", "系统参数",
						ControllerUtil.getAbsolutePath("/manager/main/configuration/modify_show"))
				.setAllowed(true, false));

		/* 通用用户显示模块 */
		menu.addMenuItem(MenuItem.getInstance("account", null, "<i class=\"iconfont nav-account-btn\">&#xf5040;</i>")
				.setStyle("width: 40px;").setSeparator(true));

		menu.addMenuItem(MenuItem.getInstance("modify", "account", "账户设置").setOnClick("openDialog('"
				+ ControllerUtil.getAbsolutePath("/manager/main/user/modify_self_show") + "',500,515,{title:'账户设置'})"));

		menu.addMenuItem(MenuItem.getInstance("online", "account", "在线用户")
				.setOnClick("openDialog('" + ControllerUtil.getAbsolutePath("/manager/main/onlineuser/onlineuser_list")
						+ "',960,500,{title:'在线用户'})"));

		menu.addMenuItem(MenuItem.getInstance("logout", "account", "系统退出")
				.setOnClick("top.location.href='" + ControllerUtil.getAbsolutePath("/admin/logout") + "'"));
		modelAndView.addObject("topMenuHtml", menu.parse());
		return modelAndView;
	}
}